<template>
	<view style="">
		<view class="top"></view>
		<view class="swiper">
			<u-swiper :list="bannerList" name="url" height="167" img-mode="scaleToFill"></u-swiper>
		</view>
		<view class="column_cate">
			<view class="column_box">
				<view class="column_box_v" @click="toPage('/pagesA/doctorList/doctorList')">
					<image src="../../static/column_msmy.png"></image>
					<text>名师名医</text>
				</view>
				<view class="column_box_v" @click="toPage(`/pagesA/commonPage/index?type=1&name=医考题库`)">
					<image src="../../static/column_jkkt.png"></image>
					<text>医考题库</text>
				</view>
				<view class="column_box_v" @click="toPage(`/pagesA/commonPage/index?type=2&name=商标专利`)">
					<image src="../../static/column_zcjs.png"></image>
					<text>商标专利</text>
				</view>
				<view class="column_box_v" @click="toPage(`/pagesA/commonPage/index?type=3&name=继续教育`)">
					<image src="../../static/column_jxjy.png"></image>
					<text>继续教育</text>
				</view>

			</view>
			<view class="column_box">
				<view class="column_box_v" @click="toPage('/pagesA/commonPage/index?type=7&name=养生知识')">
					<image src="../../static/column_yszs.png"></image>
					<text>养生知识</text>
				</view>
				<view class="column_box_v" @click="toPage(`/pagesA/commonPage/index?type=8&name=康复知识`)">
					<image src="../../static/column_kfzs.png"></image>
					<text>康复知识</text>
				</view>
				<view class="column_box_v" @click="toPage(`/pagesA/commonPage/index?type=9&name=中医知识`)">
					<image src="../../static/column_zyzs.png"></image>
					<text>中医知识</text>
				</view>
				<view class="column_box_v" @click="toPage(`/pagesA/commonPage/index?type=10&name=救护知识`)">
					<image src="../../static/column_jhzs.png"></image>
					<text>救护知识</text>
				</view>
			</view>
		</view>
		<view>
			<view class="recommended">
				<view class="recommended_left"></view>
				<view class="recommended_text">推荐医生</view>
			</view>
			<doctorList ref="doctorList"></doctorList>
		</view>
	</view>

</template>

<script>
	import {
		getBannerApi,
		getProjectCodeApi
	} from '../../common/API/userInfoApi.js'
	import {
		doctorList
	} from '../../components/doctorList.vue'
	import {
		mapMutations,
		mapState
	} from 'vuex'
	import {
		getDoctorListApi,
		apprenticeshipApi
	} from '../../common/API/doctorApi.js'
	export default {
		components: {
			doctorList
		},
		data() {
			return {
				bannerList: [{
					url: ''
				}],
				hasData: true,
				total: 0,
				pageNum: 1,
				doctorListSearch: []
			}
		},
		computed: {
			...mapState('user', ['ylUserInfo'])
		},
		methods: {
			...mapMutations('user', ['MusetToken', 'MusetUserInfo']),
			async getBanner() {
				const res = await getBannerApi("220231031172250A002")
				if (res.status === 200) {
					this.bannerList = res.data
				}
			},
			async listDoctor() {
				try {
					let res = await getDoctorListApi({
						pageNum: this.pageNum,
						pageSize: 10,
						// enterpriseCodes: [this.ylUserInfo.enterpriseCode]
					})
					if (res.status == 200) {
						this.doctorListSearch = this.doctorListSearch.concat(res.data.records)
						this.total = res.data.total
						this.$refs.doctorList.changeDoctorLists(this.doctorListSearch)
					}
				} catch {

				}

			}
		},
		async onLoad(option) {
			// uni.startPullDownRefresh();
			if (this.ylUserInfo.role == null) {
				console.log('进判断了')
			}
			this.getBanner()
			// this.listDoctor()
		},
		onShow() {
			// 强制刷新子组件
			this.hasData = false;
			this.$nextTick(() => {
				this.hasData = true;
			})
			this.doctorListSearch = []
			this.pageNum = 1
			this.listDoctor()
		},
		onReachBottom() {
			console.log('上拉刷新')
			if (this.doctorListSearch.length >= this.total) {
				return uni.$showMsg('已经到底了')
			}
			this.pageNum = this.pageNum + 1
			this.listDoctor()
		},
	}
</script>

<style lang="scss" scoped>
	.recommended {
		margin: 24rpx 0 10rpx 34rpx;
		display: flex;
		justify-content: left;

		.recommended_left {
			width: 10rpx;
			height: 30rpx;
			margin-top: 13rpx;
			border-radius: 5px;
			background-color: #00B4C7;
		}

		.recommended_text {

			margin-left: 10rpx;
			color: #333333;
			font-weight: 500;
			font-size: 40rpx;
			font-style: normal;
			text-decoration: none;
			text-align: center;
		}
	}

	.top {
		height: 235rpx;
		background: linear-gradient(180deg, rgba(0, 180, 199, 1) 0%, rgba(248, 248, 248, 1) 100%);
	}

	.swiper {
		height: 167px;
		margin-top: -200rpx;
		margin-left: 32rpx;
		margin-right: 32rpx;

		/deep/ .u-swiper {
			border-radius: 16rpx !important;
		}
	}

	.column_cate {
		margin-top: 32rpx;
		background-color: #FFFFFF;
		margin-left: 32rpx;
		margin-right: 32rpx;
	}

	.column_box {
		display: flex;
		justify-content: space-around;
		padding-top: 16rpx;
		padding-bottom: 16rpx;
		border-radius: 16rpx;

		.column_box_v {
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 90rpx;
				height: 90rpx;
				margin-bottom: 10rpx;
			}

			text {
				font-family: PingFangSC;
			}

		}

	}
</style>